{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-02-08T08:26:16.103823Z",
     "start_time": "2025-02-08T08:26:16.074821Z"
    }
   },
   "source": [
    "# Given eigenvalues\n",
    "eigenvalues = [\n",
    "    104.65, 37.0896, 37.0896, 8.68533, 8.67043, 3.21861, 3.21861, 1.66289, 1.66243, 1.09088, \n",
    "    0.992222, 0.992222, 0.777828, 0.777828, 0.647008, 0.642505, 0.560433, 0.554113, 0.441401, \n",
    "    0.441401, 0.384516, 0.384516, 0.321094, 0.317748, 0.288251, 0.282351, 0.240139, 0.240139, \n",
    "    0.222238, 0.222238, 0.185139, 0.18468, 0.178741, 0.176751, 0.146469, 0.146469, 0.142518, \n",
    "    0.142518, 0.11881, 0.118192, 0.116088, 0.114128, 0.107942, 0.103657, 0.103657, 0.0982154, \n",
    "    0.0971971, 0.0971971, 0.0964215, 0.0956897\n",
    "]\n",
    "\n",
    "# Calculate total energy (sum of eigenvalues)\n",
    "total_energy = sum(eigenvalues)\n",
    "\n",
    "# Sort the eigenvalues in descending order\n",
    "sorted_eigenvalues = sorted(eigenvalues, reverse=True)\n",
    "\n",
    "# Calculate the cumulative energy\n",
    "cumulative_energy = 0\n",
    "count = 0\n",
    "\n",
    "for eigenvalue in sorted_eigenvalues:\n",
    "    cumulative_energy += eigenvalue\n",
    "    count += 1\n",
    "    if cumulative_energy / total_energy >= 0.95:\n",
    "        break\n",
    "\n",
    "count  # Number of kernels required to reach 90% of the total energy\n"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "12"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 1
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "4ed0c1d0f044d4de"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
